﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DaoHam
{
    public class BieuThucTich : DaThuc
    {
        public BieuThucTich(BieuThuc _u, BieuThuc _v)
            : base(_u, _v)
        {
        }

        public override BieuThuc TinhDaoHam()
        {
            if (varDaoHam == null)
            {
                varDaoHam = new BieuThucTong(
                                    new BieuThucTich(u.TinhDaoHam(), v),
                                    new BieuThucTich(v.TinhDaoHam(), u)
                                   );
            }
            return varDaoHam;
        }

        public override float TinhBieuThuc(float x)
        {
            return u.TinhBieuThuc(x) * v.TinhBieuThuc(x);
        }

        public override string XuatBieuThuc()
        {
            return "(" + u.XuatBieuThuc() + "*" + v.XuatBieuThuc() + ")";
        }

        public override string ToString(Convert cv)
        {
            return cv.ToString(u, v, "*");
        }
    }
}
